# Maintainer: Oleg Rakhmanov <oleg [at] archlinuxarm [dot] org>

pkgname=cryptodev-dkms
_pkgname=${pkgname%-*}
cryptodev_commit=e0c25e289d6baf1d83c2b9cb523d3bc237d0c0c9

pkgver=1.12
pkgrel=1

pkgdesc="Cryptodev module to take advantage of hardware crypto engines in userspace"
arch=('arm' 'armv6h' 'armv7h' 'aarch64')
url="https://github.com/cryptodev-linux/cryptodev-linux"
license=('GPL2')
depends=('dkms')
install=${pkgname}.install
provides=('cryptodev_friendly')
source=("cryptodev-${cryptodev_commit}.tar.gz::https://github.com/cryptodev-linux/cryptodev-linux/archive/${cryptodev_commit}.tar.gz"
        'dkms.conf')

sha256sums=('4ba2036aff4d1f82fb67d04d58a547367f5821340493eb154bf3d3518e91ee5b'
            'c42865a4a800a4927619ac5ed742be59a6d960af8295727af909e9ea9587f3da')

package() {
  cd "${srcdir}"

  local install_dir="${pkgdir}/usr/src/${_pkgname}-${pkgver}"

  # Copy dkms.conf
  install -Dm644 dkms.conf "${install_dir}/dkms.conf"

  # Set name and version
  sed -e "s/@_PKGNAME@/${_pkgname}/" \
      -e "s/@PKGVER@/${pkgver}/" \
      -i "${install_dir}/dkms.conf"

  # Copy sources
  cd "cryptodev-linux-${cryptodev_commit}"

  for d in $(find . -type d)
  do
    install -dm755 "${install_dir}/$d"
  done

  for f in $(find . -type f)
  do
    install -m644 "$f" "${install_dir}/$f"
  done
}
